package com.tensai.study.java.features.JDK8.annotations;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Target;

/**
 * @author Tensai
 */
@Repeatable(Authors.class)
@interface Author {
	String name();
}

/**
 * @author Tensai
 */
@interface Authors {
	Author[] value();
}

/**
 * @author Tensai
 */
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
@interface TestAn {
	String value() default "default";
}

/**
 * 标识某注解可以在同一个声明上使用多次
 *
 * @author Tensai
 */
@Author(name = "a")
@Author(name = "b")
@Slf4j
public class RepeatableTest {
	@TestAn("a")
	private final Object name = "name";

	@Test
	public void test() {
		log.info(name.toString());
		String author = (@TestAn("a") String) name;
		log.info(author);
	}
}

